/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.dusa.switco;

/**
 *
 * @author vdusa
 */
public class NearestEventHolder {
    Event event = null;
    MovingDirection direction;
    
    private NearestEventHolder(){};
    
    public NearestEventHolder(MovingDirection direction){
        this.direction = direction;
    }
    
    public void compare(Event event){
        switch(direction){
        case BACKWARDS:
            if (this.getEvent()==null || this.getEvent().getTime() < event.getTime()) {
                this.event = event;
            }
            break;
        case FORWARD:
            if (this.getEvent()==null || this.getEvent().getTime() > event.getTime()) {
                this.event = event;
            }
            break;
        }
    }
    
    public Event getEvent(){
        return event;
    }
}
